package cn.hyh.controller;

import cn.hyh.component.TestCustomer;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @auther :hyh
 * @desc :
 * @date :2020/1/21
 */
@RestController("/init")
public class TestInitBinderController  {

	@InitBinder    //写在该类中 ，只对该controller类有效，如果想要对全局的有效，则可以写在@controllerAdvice 作用的类中。
	public void   testInitBinder(WebDataBinder binder){
		binder.registerCustomEditor(String.class, new TestCustomer());
	}

	@RequestMapping("/binder1")
	public String test1(String name) {

		return name;
	}

	@RequestMapping("/binder2")
	public String test2(String name) {

		return name;
	}
}
